# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=libkface
pkgver=16.12.1
pkgrel=2
pkgdesc="A Qt/C++ wrapper around LibFace library to perform face recognition and detection over pictures"
url="https://www.kde.org/applications/graphics/"
arch=(x86_64)
license=(GPL LGPL FDL)
depends=(qt5-base opencv)
makedepends=(extra-cmake-modules)
source=("https://download.kde.org/stable/applications/$pkgver/src/$pkgname-$pkgver.tar.xz"{,.sig} libkface-opencv-3.2.patch)
sha256sums=('b120023ccb54bbb6dc89a7f973ea2aaaa983b4ed'
          'SKIP'
          'fa635d76932da97d0687eb5e41a9f3f927d22639')
validpgpkeys=(CA262C6C83DE4D2FB28A332A3A6A4DB839EAA6D7  # Albert Astals Cid <aacid@kde.org>
              F23275E4BF10AFC1DF6914A6DBD2CE893E2D1C87) # Christoph Feck <cfeck@kde.org>

prepare() {
  mkdir -p build

  cd $pkgname-$pkgver
# Fix build with opencv 3.2
#  patch -p1 -i ../libkface-opencv-3.2.patch
   sed -i -e 's|OPENCV_TEST_VERSION(3,1,0)|OPENCV_TEST_VERSION(3,2,0)|' src/recognition-opencv-lbph/facerec_borrowed.cpp
   sed -i -e 's|OPENCV_TEST_VERSION(3,1,0)|OPENCV_TEST_VERSION(3,2,0)|' src/recognition-opencv-lbph/facerec_borrowed.h
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTING=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DENABLE_OPENCV3=ON
  make
}

package() {
  cd build
  make DESTDIR="$pkgdir" install
}
